package com.zmj.sy.mom.srv.aps.bean.bo;

import cn.hutool.core.date.DatePattern;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.time.LocalDateTime;

@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
public class DiffTime {

    private Integer id;

    private String plmId;

    private String materName;

    private String phaseCode;

    private LocalDateTime sourcePlanStartDateTime;

    private LocalDateTime sourcePlanEndDateTime;

    private Integer sourceStationId;

    private LocalDateTime targetPlanStartDateTime;

    private LocalDateTime targetPlanEndDateTime;

    private Integer targetStationId;

    private String operationCode;

    public DiffTime(Integer id, String plmId, String materName, String phaseCode, LocalDateTime sourcePlanStartDateTime, LocalDateTime sourcePlanEndDateTime, Integer sourceStationId) {
        this.id = id;
        this.plmId = plmId;
        this.materName = materName;
        this.phaseCode = phaseCode;
        this.sourcePlanStartDateTime = sourcePlanStartDateTime;
        this.sourcePlanEndDateTime = sourcePlanEndDateTime;
        this.sourceStationId = sourceStationId;
    }

    @Override
    public String toString() {

        StringBuilder sb = new StringBuilder();


        sb.append(", 源工位:");
        sb.append(sourceStationId);

        sb.append(", 目标工位:");
        sb.append(targetStationId);

//        sb.append(", 操作:");
//        if(operationCode == null){
//            sb.append("不排");
//        } else {
//            sb.append(operationCode);
//        }

        sb.append(", 修改前-开始:");
        if(sourcePlanStartDateTime != null){
            sb.append(sourcePlanStartDateTime.format(DatePattern.NORM_DATETIME_FORMATTER));
        } else {
            sb.append("0000-00-00 00:00:00");
        }
        sb.append(", 修改前-结束:");
        if(sourcePlanEndDateTime != null){
            sb.append(sourcePlanEndDateTime.format(DatePattern.NORM_DATETIME_FORMATTER));
        } else {
            sb.append("0000-00-00 00:00:00");
        }

        sb.append(", 修改后-开始:");
        if(targetPlanStartDateTime != null){
            sb.append(targetPlanStartDateTime.format(DatePattern.NORM_DATETIME_FORMATTER));
        } else {
            sb.append("0000-00-00 00:00:00");
        }

        sb.append(", 修改后-结束:");
        if(targetPlanEndDateTime != null){
            sb.append(targetPlanEndDateTime.format(DatePattern.NORM_DATETIME_FORMATTER));
        } else {
            sb.append("0000-00-00 00:00:00");
        }

        sb.append(", 名称:");
        sb.append(materName);

        sb.append(", PLMID:");
        sb.append(plmId);

        sb.append(", 工序:");
        sb.append(phaseCode);


        sb.delete(0, 2);
        return sb.toString();
    }
}
